package com.agriculture.data_demo.repository;

import com.agriculture.data_demo.entity.sys.HogBatchEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author morningbear
 * @date 20.10.7
 */
@Repository
public interface HogBatchRepository extends JpaRepository<HogBatchEntity, Integer> {

    @Query(value = "select * from hog_batch", nativeQuery = true)
    Page<HogBatchEntity> findAll(PageRequest of);

    /**
     *
     * @param fence 猪舍类型
     * @return 根据猪舍类型寻找
     */
    @Query(value = "select * from hog_batch where fence = ?1", nativeQuery = true)
    Page<HogBatchEntity> findByFence(String fence, Pageable pageable);

}
